package com.spider.test03.demo2;

public class Vehicle {
    private int speed;
    private int size;

    public Vehicle(){

    }

    public Vehicle(int speed, int size) {
        this.speed = speed;
        this.size = size;
    }

    public int getSpeed() {
        return speed;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }
    // 设置速度方法
    public void setSpeed(int speed) {
        this.speed = speed;
    }
    // 移动方法
    public void move() {
        System.out.println("交通工具正在以速度 " + speed + " 移动");
    }

    // 加速方法
    public void speedUp() {
        this.speed += 10;
        System.out.println("加速后当前速度: " + this.speed);
    }

    // 减速方法
    public void speedDown() {
        if (this.speed >= 10) {
            this.speed -= 10;
        } else {
            this.speed = 0;
        }
        System.out.println("减速后当前速度: " + this.speed);
    }
}
